//go:build unix

package fd

import (
	"syscall"

	"golang.org/x/sys/unix"

	"gitee.com/hasika/common-server/conn/inet"
)

func SetReusePort(rawCon syscall.RawConn) error {
	err := rawCon.Control(func(fd uintptr) {
		setReusePortErr := syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
		if setReusePortErr != nil {
			inet.Log.Errorf("set reuse port error %+v", setReusePortErr)
		}
	})
	return err
}
